import { createHttpRequest, createErrorHandle } from '@fssc/admin';

export const BASE_URL =
  (import.meta.env.DEV ? import.meta.env.VITE_PROXY_PREFIX : '') + import.meta.env.VITE_APP_API_BASEURL;

const request = createHttpRequest({
    baseURL: BASE_URL,
    timeout: 60 * 1000,
    successCodes: [1, 200, '1000_0001_0000'],
    errorHandle: createErrorHandle(() => {
      console.log('sadf')
    }),
    // transformResponse: [
    //   function responseTransform(data, _axiosHeader, status) {
    //     if (status == 200 && typeof data === 'string') {
    //       let responseData = JSON.parse(data);

    //       return responseData;
    //     }
    //     return data;
    //   }
    // ],
  },
  function(request: any) {
    request.headers.token = 'bm2frhxf8ghumsze';
    request.headers.Source = 'fssc';
  }
);

export default request;
